package com.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Student;
import org.apache.ibatis.annotations.*;


import java.util.List;

@Mapper

public interface StudentMapper   extends BaseMapper<Student> {


   /* @Select("select * from student where student_name like concat('%',#{name},'%')")
    List<Student> selectAll(String student_name);*/

    @Select("select * from student where( student_name like concat('%',#{student_name},'%') or student_id like  concat('%',#{student_name},'%') or student_grade like  concat('%',#{student_name},'%') )and student_deleted = 0 limit #{start},#{pageSize}")
    List<Student> selectPage(@Param("student_name") String student_name,@Param("start")Integer start,@Param("pageSize")Integer pageSize);


    @Select("select count(*) from student where student_name like concat('%',#{student_name},'%')  and student_deleted = 0" )
     Integer selectTotal(@Param("student_name") String student_name);

    @Insert("insert into student(student_name,student_id,student_nation,student_grade,student_college,student_info) values(#{student_name},#{student_id},#{student_nation},#{student_grade},#{student_college},#{student_info})")
    int insert(Student student);

   @Update("update student set student_name =#{student_name},student_id =#{student_id},student_nation =#{student_nation},student_grade =#{student_grade},student_college =#{student_college},student_info =#{student_info} where student_no =#{student_no} and student_deleted = 0")
    void update(Student student);

/*   @Delete("delete from student where student_no = #{student_no} ")
    void delete (Integer student_no);*/

   @Update("update Student set student_deleted=1 where student_no=#{student_no} and student_deleted=0")
   void delete (Integer student_no);






//    @Select()
//    @Results(
//            {
//                    @Result(column = "student_id", property ="student_id"),
//                    @Result(column = "student_name", property ="student_name"),
//                    @Result(column = "student_nation", property ="student_nation"),
//                    @Result(column = "student_grade", property ="student_grade"),
//                    @Result(column = "student_school", property ="student_school"),
//                    @Result(column = "student_scholarship_name", property ="student_scholarship_name"),
//                    @Result(column = "student_scholarship_id", property ="scholarships",javaType = List.class,
//                            many =@Many(select = "com.example.mapper.ScholarshipMapper.selectByScholarship_id")
//                    )
//            }
//    )
//    List<Student>  selectAllStudentAndScholarships();  //查询学生表
//
//
//
//    @Select("select * from student")
//    public List<Student> find();



}
